package jp.co.libgate.controller;

import jp.co.libgate.model.Attend;
import jp.co.libgate.service.AttendService;

import org.slim3.controller.Navigation;
import org.slim3.util.RequestMap;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

public class AttendListController extends JsonController {
    private static final Logger log = Logger.getLogger(AttendListController.class.getName());

    private AttendService service = new AttendService();

    @Override
    public Navigation run() throws Exception {
        try{
            List<Attend> list = service.getList((String)(new RequestMap(request).get("id")));
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("result", "true");
            map.put("data", list);
            json(map);

        }catch(Exception e){
            Map<String,String> msg = new HashMap<String,String>();
            msg.put("result","false");
            msg.put("msg","エラーが発生しました");
            json(msg);
        }

        return null;
    }
}
